package com.tamecode.chapter06.sec45;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.GregorianCalendar;
import java.util.Locale;

/**
 * @Author: Qiongchao
 * @Version: 1.0.0
 * @Date: 2023/9/27
 */
public class ApplicationContextStarter {
    public static void main(String[] args) throws InterruptedException {
        String[] configs = {"sec6-45/i18n/beans-messageSource.xml"};
        ApplicationContext ctx = new ClassPathXmlApplicationContext(configs);
        //①直接通过容器访问国际化信息资源
        Object[] params = {"John", new GregorianCalendar().getTime()};
        String str1 = ctx.getMessage("greeting.common",params,Locale.US);
        String str2 = ctx.getMessage("greeting.morning",params,Locale.CHINA);
        System.out.println(str1);
        System.out.println(str2);
    }
}
